@echo off
cd /d %~dp0
chcp 65001	
setlocal enabledelayedexpansion
set file_name=prj_date
set file=%file_name%.h
set file_tmp=%file_name%_tmp.h
set file_bak=%file_name%_bak.h
for %%i in ("%file%") do (
    set file_path=%%~fi
)
for %%i in ("%file_tmp%") do (
    set file_temp_path=%%~fi
)
for %%i in ("%file_bak%") do (
    set file_bak_path=%%~fi
)
del %file_temp_path%
set error_str=#error please_use_auto_pre_compile
set "today_str=#define FW_STRING_DATE"
for /f "delims=" %%i in ('type "%file_path%"') do (             				
    set str=%%i
    set "str_test=!str: =!"    
    if not !str_test!.==. (    
		    set "str_head=!str:~0,22!"
		    if !str_head! EQU !today_str!	(		    	
		    	echo %error_str%>>%file_temp_path%
		    ) 
		    echo !str!>>%file_temp_path%		    
    )
)
copy "%file_path%" "%file_bak_path%" >nul 2>nul
move "%file_temp_path%" "%file_path%"